package logic

import (
	"car_srv/models"
	"context"

	"car_srv/car"
	"car_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserUpdateStatusLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserUpdateStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserUpdateStatusLogic {
	return &UserUpdateStatusLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 修改用户状态
func (l *UserUpdateStatusLogic) UserUpdateStatus(in *car.UserUpdateStatusRequest) (*car.UserUpdateStatusResponse, error) {
	var user models.User
	user.ID = uint(in.Id)
	user.Status = in.Status
	if err := user.UpdateStatus(); err != nil {
		logx.Info("冻结用户失败", err)
		return nil, err
	}

	return &car.UserUpdateStatusResponse{
		Id: int64(user.ID),
	}, nil
}
